package com.service.thread;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * 描述：
 * 定义一个传递对象的Ttl
 *  就是个简单的get set
 *  如果是字符串传递，请使用MDC
 * @author xianggj
 * @Date 2021/11/18 18:38
 **/
public class TtlCustomMap<T> {

    private final ThreadLocal<T> copyOnInheritThreadLocal = new TransmittableThreadLocal<>();

    private T get(){
        return copyOnInheritThreadLocal.get();
    }

    private void Set(T t){
        copyOnInheritThreadLocal.set(t);
    }

    private void remove(){
        copyOnInheritThreadLocal.remove();
    }

}
